package com.xuhf.boot;

import com.alibaba.fastjson.JSONObject;
import com.xuhf.config.Config;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "01-boot-hello",consumerGroup = Config.CONSUMER_GROUP, messageModel = MessageModel.CLUSTERING)
public class MessageConsumer implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println(JSONObject.toJSONString(messageExt));
        System.out.println(new String(messageExt.getBody()));
    }
}
